<template>
  <div class="cmt-wrapper">
    <h4 class="cmt-title">
      评论
    </h4>
    <!-- 输入框 -->
    <div class="cmt-input">
      <el-input
        type="textarea"
        resize="none"
        :rows="2"
        placeholder="请说点什么吧..."
        v-model="textarea">
      </el-input>
    </div>
    <!-- 添加图片和提交按钮 -->
    <div class="cmt-ctrl">
      <!-- 添加图片按钮 -->
      <div class="cmt-pics">
        <el-upload
          action="https://jsonplaceholder.typicode.com/posts/"
          list-type="picture-card"
          :on-preview="handlePictureCardPreview"
          :on-remove="handleRemove">
          <i class="el-icon-plus"></i>
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
          <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
      </div>
      <!-- 提交按钮 -->
      <div class="cmt-button">
        <button>提交</button>
      </div>
    </div>
    <!-- 评论内容 -->
    <div class="cmt-content">
      <CurrentComment />
    </div>
  </div>
</template>

<script>
import CurrentComment from '@/components/post/CurrentComment'
export default {
  components:{
    CurrentComment,
  },
  data(){
    return{
      textarea: '',
      dialogImageUrl: '',
      dialogVisible: false,      
    }
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    }
  }
}
</script>
<style lang="less" scoped>
.cmt-wrapper{
  .cmt-title{
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 20px;

  }
  .cmt-input{
    margin-bottom: 20px;
  }
  .cmt-ctrl{
    display: flex;
    position: relative;
    margin-bottom: 20px;
    .cmt-button{
      button{
        position: absolute;
        width: 56px;
        height: 28px;
        border: none;
        color: #ffffff;
        background-color: #409eff;
        border-radius: 5px;
        line-height: 28px;
        outline: none;
        top: 0;
        right: 0;
      }
    }
  }
  // .cmt-list{
  //   margin-top: 30px;
  //   border: 1px solid #dddddd;
  //   height: 500px;
  //   .cmt-item{
  //     padding: 20px 0;
  //     border-bottom: 1px dashed #ddd;
  //   }
  // }
}
</style>